import type { VueTag, Options } from "./type";

// create web-types.json to provide autocomplete in JetBrains IDEs
export function genWebTypes(tags: VueTag[], options: Options) {
  const _tags = tags.map((item) => ({
    name: item.name,
    source: {
      symbol: item.name
        .split("-")
        .map((str) =>
          str.replace(/\b\w/g, function (match) {
            return match.toUpperCase();
          }),
        )
        .join(""),
    },
    slots: item.slots,
    description: item.description,
    props: item.attributes,
    js: { events: item.events },
  }));
  return {
    $schema: "http://json.schemastore.org/web-types",
    framework: "vue",
    name: options.name,
    version: options.version,
    "js-types-syntax": "typescript",
    contributions: {
      html: {
        "vue-components": _tags,
        attributes: [],
      },
    },
  };
}
